<?php
require("db_con.php");
 $bbsid=isset($_GET['id']) ? $_GET['id']:0;
 if(empty ($_POST))
 {
      $rs=$db->query("select*from t_message where id='{$bbsid}'");
      $row=$rs->fetch_assoc();
      require("edit_html.php");
 }
 else{
 $username=$_REQUEST['username'];
 $sex=$_REQUEST['sex'];
 $message=$_REQUEST['message'];
 $imgurl=$_REQUEST['imgurl'];
 date_default_timezone_set('Asia/Shanghai');
 $m_date=date("Y-m-d h:i:s");
 $sql="update t_message set username='$username',sex='$sex',message='$message',imgurl='$imgurl',m_date='$m_date' where id='{$bbsid}'";
 $rs=$db->query($sql);
 if ($rs==true)
 {
     echo "<script language='javascript' type='text/javascript'>";
     echo "alert('修改成功!');";
     echo "window.location.href='index.php';";
     echo "</script>";
 }
 else{
      echo "<script language='javascript' type='text/javascript'>";
     echo "alert('修改失败!');";
     echo "window.location.href='index.php';";
     echo "</script>";
 }
 }
